home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 3: CDPD 3 / Almathera Ten on Ten - Disc 3: CDPD3.iso / ab20 / ab20_archive / languages / assembly / powervisor_113.lzh / Source / mkeys.explained < prev    next >
Text File  |  1991-09-28  |  12KB  |  260 lines

  1. ;Install memory window keys
  2. ;
  3. ;This file is the same as 'mkeys' except for the extra comments.
  4. ;If you read this file carefully you will surely know a lot more about
  5. ;PowerVisor.
  6. ;
  7. ;The general syntax in this file is :
  8. ;
  9. ;  <command>
  10. ;  <<< general explanation of command (behaviour, expected arguments, ...)
  11. ;     {argument list}
  12. ;  >>> execution of command (what happens, returned result, ...)
  13. ;     ...
  14. ;
  15.  
  16. -openpw memory 0 0 640 200
  17.    ;Open a physical window 'memory'. In this physical window we will open
  18.    ;our logical window. If you want the 'memory' logical window in the
  19.    ;'Main' (the default) physical window you can remove this command
  20.    ;and replace the first 'memory' in the next command with 'main'.
  21.    ;You also need to replace all occurences of 'closepw' in this file
  22.    ;with 'closelw'.
  23.    ;The '-' in front of this line prevents output from the 'openpw'
  24.    ;command to appear on your default logical window (probably 'Main').
  25.    ;This is a bit cleaner.
  26.  
  27. -openlw memory memory 80 40
  28.    ;Open the 'memory' logical window in the 'memory' physical window.
  29.    ;The output of our memory view will appear in this logical window.
  30.    ;There are 80 columns and 40 rows in the logical window.
  31.  
  32. -setflag memory 128+32 128+32
  33.    ;Here we set some flags for our logical window.
  34.    ;The 128 flag is set indicating that the user can't interrupt the output
  35.    ;in the 'memory' logical window with <Esc>
  36.    ;The 32 flag is set indicating that the home position of the logical
  37.    ;window is equal to the topmost position. The home position is the
  38.    ;place where all output starts if the window was just cleared.
  39.  
  40. memptr=0
  41.    ;Our variable containing the pointer to the memory we are currently
  42.    ;viewing. We start at address 0
  43.  
  44. alias _vm 'on memory {home;m memptr}'
  45.    ;To make life easier for us, we install this alias command.
  46.    ;This command refreshes the memory display on the 'Memory' logical
  47.    ;window.
  48.  
  49. alias _ra 'remattach []'
  50.    ;To make life easier for us, we install this alias command.
  51.    ;This command removes a key attachement (see later)
  52.  
  53. _vm
  54.    ;Refresh the memory display.
  55.  
  56.    ;The following commands install all the keys used to scroll in
  57.    ;the memory view. The variables _k<x> are used so that we can
  58.    ;remove these keys later.
  59.    ;The 'attach' command attaches a command to a key. The first argument
  60.    ;is the command string to execute when the user later presses that key.
  61.    ;The second and third arguments are the key code and qualifier. The
  62.    ;last argument indicates if we should see feedback for the command on
  63.    ;the screen ('e' means no feedback).
  64.    ;I will only explain the the most difficult key assignment. The other
  65.    ;ones are similar and easier.
  66.  
  67. _k1={attach '{memptr=memptr-16;_vm}' 03e 01 e}
  68. _k2={attach '{memptr=memptr+16;_vm}' 01e 01 e}
  69. _k3={attach '{memptr=memptr-1;_vm}' 02d 01 e}
  70. _k4={attach '{memptr=memptr+1;_vm}' 02f 01 e}
  71. _k5={attach '{memptr=memptr-(20*16);_vm}' 03f 01 e}
  72. _k6={attach '{memptr=memptr+(20*16);_vm}' 01f 01 e}
  73. _k7={attach '_vm' 02e 01 e}
  74. _k8={attach '{getstring \'Give address\' 256;memptr=eval(input);_vm}' 0f 01 e}
  75. _k9={attach '{v if((mode)&3,if(((mode)&3)==1,{mode word},{mode byte}),{mode long});_vm}' 03c 01 e}
  76.    ;_k9=
  77.    ;<<< assignment to _k9, argument is :
  78.    ;  {attach '{v if((mode)&3,if(((mode)&3)==1,{mode word},{mode byte}),{mode long});_vm}' 03c 01 e}
  79.    ;>>> we evaluate this expression :
  80.    ;  {
  81.    ;  <<< group operator, argument is :
  82.    ;     attach '{v if((mode)&3,if(((mode)&3)==1,{mode word},{mode byte}),{mode long});_vm}' 03c 01 e
  83.    ;  >>> the 'attach' command is executed :
  84.    ;     attach
  85.    ;     <<< attach command, this command attaches a command to a key. This
  86.    ;     <<< command has four arguments :
  87.    ;        '{v if((mode)&3,if(((mode)&3)==1,{mode word},{mode byte}),{mode long});_vm}'
  88.    ;        03c
  89.    ;        01
  90.    ;        e
  91.    ;     <<< the first argument is the command to be assigned. The second and third
  92.    ;     <<< arguments are the code and qualifer for the key. The last argument
  93.    ;     <<< ('e') states that the command must not be added to the commandline
  94.    ;     <<< history when the key is pressed (no feedback).
  95.    ;     <<< The string is parsed, this results in :
  96.    ;        {v if((mode)&3,if(((mode)&3)==1,{mode word},{mode byte}),{mode long});_vm}
  97.    ;     >>> The key attachement is make.
  98.    ;     >>> result of 'attach' command is the pointer to the key attachement node.
  99.    ;  >>> result of group operator is the pointer to the key attachement node.
  100.    ;>>> _k9=pointer to the key attachement node.
  101.  
  102.    ;When the key is pressed later, the following command is executed as if it
  103.    ;was typed in at that moment :
  104.    ;{v if((mode)&3,if(((mode)&3)==1,{mode word},{mode byte}),{mode long});_vm}
  105.    ;{
  106.    ;<<< group operator, execute all arguments :
  107.    ;  v if((mode)&3,if(((mode)&3)==1,{mode word},{mode byte}),{mode long})
  108.    ;  _vm
  109.    ;>>> First execution results in :
  110.    ;  v
  111.    ;  <<< void command, evaluate all arguments :
  112.    ;     if((mode)&3,if(((mode)&3)==1,{mode word},{mode byte}),{mode long})
  113.    ;  >>> First argument is evaluated :
  114.    ;     if
  115.    ;     <<< if function, evaluate first argument, if true then evaluate
  116.    ;     <<< second argument else evaluate last argument. Arguments for
  117.    ;     <<< 'if' are :
  118.    ;        (mode)&3
  119.    ;        if(((mode)&3)==1,{mode word},{mode byte})
  120.    ;        {mode long}
  121.    ;     >>> if (mode)&3 (the last two bits of the mode variable) are not equal
  122.    ;     >>> to 0, the first string is evaluated :
  123.    ;        if
  124.    ;        <<< if function, evaluate first argument, if true then evaluate
  125.    ;        <<< second argument else evaluate last argument. Arguments for
  126.    ;        <<< 'if' are :
  127.    ;           ((mode)&3)==1
  128.    ;           {mode word}
  129.    ;           {mode byte}
  130.    ;        >>> if mode&3 is equal to 1, the first string is evaluated :
  131.    ;           {
  132.    ;           <<< group operator, argument is :
  133.    ;              mode word
  134.    ;           >>> execution of command results in the 'word' memory display
  135.    ;           >>> setting to be initialized.
  136.    ;        >>> if mode&3 is not equal to 1, the second string is evaluted :
  137.    ;           {
  138.    ;           <<< group operator, argument is :
  139.    ;              mode byte
  140.    ;           >>> execution of command results in the 'byte' memory display
  141.    ;           >>> setting to be initialized.
  142.    ;        >>> result of 'if' is that either 'word' or 'byte' is choosen
  143.    ;        >>> as the memory display setting.
  144.    ;     >>> if mode&3 is equal to 0, the second string is evaluated :
  145.    ;        {
  146.    ;        <<< group operator, argument is :
  147.    ;           mode long
  148.    ;        >>> execution of command results in the 'long' memory display setting
  149.    ;        >>> to be initialized.
  150.    ;     >>> result of this 'if' is that one of 'byte', 'word' or 'long' memory
  151.    ;     >>> display mode is choosen depending on the previous setting.
  152.    ;  >>> This is also the result of the 'void' command.
  153.    ;>>> The second argument of the group operator is also executed :
  154.    ;  _vm
  155.    ;  <<< alias for refreshing of memory display, no arguments.
  156.    ;  >>> refresh the memory display.
  157.    ;>>> this command toggles between 'byte', 'word' or 'long' memory display
  158.    ;>>> and refreshes the display.
  159.  
  160. _mkeys={attach '{closepw memory;remvar memptr;_ra \(_k1);_ra \(_k2);_ra \(_k3);_ra \(_k4);_ra \(_k5);_ra \(_k6);_ra \(_k7);_ra \(_k8);_ra \(_k9);_ra _mkeys;remvar _mkeys;unalias _vm;unalias _ra}' 01d 09 e}
  161.    ;This command installs a command on Ctrl+Shift-1 to remove all aliases and
  162.    ;all key attachements.
  163.    ;_mkeys=
  164.    ;<<< assignment to _mkeys, argument is :
  165.    ;  {attach '{closepw memory;remvar memptr;_ra \(_k1);_ra \(_k2);_ra \(_k3);_ra \(_k4);_ra \(_k5);_ra \(_k6);_ra \(_k7);_ra \(_k8);_ra \(_k9);_ra _mkeys;remvar _mkeys;unalias _vm;unalias _ra}' 01d 09 e}
  166.    ;>>> we evaluate this expression :
  167.    ;  {
  168.    ;  <<< group operator, argument is :
  169.    ;     attach '{closepw memory;remvar memptr;_ra \(_k1);_ra \(_k2);_ra \(_k3);_ra \(_k4);_ra \(_k5);_ra \(_k6);_ra \(_k7);_ra \(_k8);_ra \(_k9);_ra _mkeys;remvar _mkeys;unalias _vm;unalias _ra}' 01d 09 e
  170.    ;  >>> the 'attach' command is executed :
  171.    ;     attach
  172.    ;     <<< attach command, this command attaches a command to a key. This
  173.    ;     <<< command has four arguments :
  174.    ;        '{closepw memory;remvar memptr;_ra \(_k1);_ra \(_k2);_ra \(_k3);_ra \(_k4);_ra \(_k5);_ra \(_k6);_ra \(_k7);_ra \(_k8);_ra \(_k9);_ra _mkeys;remvar _mkeys;unalias _vm;unalias _ra}'
  175.    ;        01d
  176.    ;        09
  177.    ;        e
  178.    ;     <<< the first argument is the command to be assigned. The second and third
  179.    ;     <<< arguments are the code and qualifer for the key. The last argument
  180.    ;     <<< ('e') states that the command must not be added to the commandline
  181.    ;     <<< history when the key is pressed (no feedback).
  182.    ;     <<< The string is parsed, this results in :
  183.    ;        {closepw memory;remvar memptr;_ra 123;_ra 124;_ra 125;_ra 126;_ra 127;_ra 128;_ra 129;_ra 130;_ra 131;_ra _mkeys;remvar _mkeys;unalias _vm;unalias _ra}
  184.    ;     <<< Note how I replaced the \(_k<x>) construction with a number. This
  185.    ;     <<< number is the address of the variable _k<x> (the numbers choosen
  186.    ;     <<< in this example are completely arbitrary and are even impossible).
  187.    ;     <<< The \(<expression>) construction as used above is very useful for
  188.    ;     <<< such situations. After the key attachement is made we can simply
  189.    ;     <<< remove all _k<x> variables since the contents of these variables is
  190.    ;     <<< already fixed in the attachement string.
  191.    ;     >>> The key attachement is make.
  192.    ;     >>> result of 'attach' command is the pointer to the key attachement node.
  193.    ;  >>> result of group operator is the pointer to the key attachement node.
  194.    ;>>> _mkeys=pointer to the key attachement node.
  195.  
  196.    ;When the Ctrl+Shift-1 key is pressed later, the following command is executed
  197.    ;as if it was typed in at that moment :
  198.    ;{closepw memory;remvar memptr;_ra 123;_ra 124;_ra 125;_ra 126;_ra 127;_ra 128;_ra 129;_ra 130;_ra 131;_ra _mkeys;remvar _mkeys;unalias _vm;unalias _ra}
  199.    ;{
  200.    ;<<< group operator, execute all arguments :
  201.    ;  closepw memory
  202.    ;  remvar memptr
  203.    ;  _ra 123
  204.    ;  _ra 124
  205.    ;  _ra 125
  206.    ;  _ra 126
  207.    ;  _ra 127
  208.    ;  _ra 128
  209.    ;  _ra 129
  210.    ;  _ra 130
  211.    ;  _ra 131
  212.    ;  _ra _mkeys
  213.    ;  remvar _mkeys
  214.    ;  unalias _vm
  215.    ;  unalias _ra
  216.    ;>>> first execution results in :
  217.    ;  closepw
  218.    ;  <<< close physical window, first argument is physical window name :
  219.    ;     memory
  220.    ;  >>> physical and logical window are closed
  221.    ;>>> second argument is executed :
  222.    ;  remvar
  223.    ;  <<< remove a variable, first argument is variable name :
  224.    ;     memptr
  225.    ;  >>> 'memptr' is removed
  226.    ;>>> third argument is executed :
  227.    ;  _ra
  228.    ;  <<< remove a key attachement, first argument is pointer to attachment
  229.    ;  <<< node :
  230.    ;     123
  231.    ;  >>> attachement node is removed
  232.    ;>>> the same for all other '_ra' commands and one 'remvar' command
  233.    ;  .
  234.    ;  .
  235.    ;  .
  236.    ;>>> last two commands are executed :
  237.    ;  unalias
  238.    ;  <<< remove an alias definition :
  239.    ;     _vm
  240.    ;  >>> alias definition '_vm' is removed
  241.    ;>>> equivalent for last 'unalias' command.
  242.    ;>>> Everything is cleaned up.
  243.  
  244. remvar _k1 _k2 _k3 _k4 _k5 _k6 _k7 _k8 _k9
  245.    ;Remove all variables used in this script.
  246.    ;We can do this now because we have burned the contents of these variables
  247.    ;fixed in the key attachement string needed to remove everything.
  248.  
  249. print '\0aShift in combination with the following keys on numeric keypad :\0a'
  250. print '   8 (Up)    scroll one line up\0a'
  251. print '   2 (Down)  scroll one line down\0a'
  252. print '   9 (PgUp)  scroll one page up\0a'
  253. print '   3 (PgDn)  scroll one page down\0a'
  254. print '   4 (Left)  scroll one byte left\0a'
  255. print '   6 (Right) scroll one byte right\0a'
  256. print '   5         refresh display\0a'
  257. print '   0         ask new address\0a'
  258. print '   .         switch between byte/word and long mode\0a'
  259. print 'Ctrl+Shift 1 to remove display\0a'
  260.